function OpenFileDialog(title, owner, filter){
	var OpenFileName = Interop.Allocate(84);
	var s_file = Interop.Allocate(10242);
	var s_filter = Interop.Allocate((filter.length + 1) << 1);
	var s_title = Interop.Allocate((title.length + 1) << 1);
	WriteMultiStringW(s_filter, filter);
	s_file.WriteString(0, Space(5120));
	s_title.WriteString(0, title);
	with(OpenFileName){
		WriteDWORD(0, 88);
		WriteDWORD(4, owner);
		WriteDWORD(12, s_filter.DataPtr);
		WriteDWORD(28, s_file.DataPtr);
		WriteDWORD(32, 5120);
		WriteDWORD(48, s_title.DataPtr);
		WriteDWORD(52, 528900);
		}
	if(Interop.Call("comdlg32", "GetOpenFileNameW", OpenFileName)){
		var fs = [];
		var files = ReadMultiStringW(s_file);
		var root = files[0];
		if(files.length > 1){
			for(x in files)
				fs.push(root + "\\" + files[x]);
			fs.shift();
			} else
			fs.push(root);
		return fs;
		}
	return [];
	}

function ReadMultiStringW(d){
	var files = [], pos = 0;
	var fetch = d.ReadString(0);
	do{files.push(fetch);}while(fetch = d.ReadString(pos += (fetch.length + 1) << 1));
	return files;
	}

function WriteMultiStringW(d, str){
	d.WriteString(0, str);
	for(pos = str.indexOf("|");pos != -1;pos = str.indexOf("|", pos+1))
		d.WriteWORD(pos << 1, 0);
	}

function Space(n){
	var s = "";
	while(s.length < n)
		s += " ";
	return s;
	}